dnd: Rename headers
authorMatthias Clasen <mclasen@redhat.com>
Mon, 2 Jul 2018 11:39:09 +0000 (13:39 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 2 Jul 2018 13:00:50 +0000 (15:00 +0200)
Rename gdkdnd.h to gdkdrag.h, to go along with gdkdrop.h

This commit includes the necessary updates to the X11, Wayland
and Broadway backends. Other backends have to be updated separately.

17 files changed:
gdk/broadway/gdkdnd-broadway.c
gdk/gdk.h
gdk/gdkdnd.c [deleted file]
gdk/gdkdnd.h [deleted file]
gdk/gdkdndprivate.h [deleted file]
gdk/gdkdrag.c [new file with mode: 0644]
gdk/gdkdrag.h [new file with mode: 0644]
gdk/gdkdragprivate.h [new file with mode: 0644]
gdk/gdkevents.c
gdk/gdkevents.h
gdk/gdkeventsprivate.h
gdk/gdkinternals.h
gdk/meson.build
gdk/wayland/gdkdnd-wayland.c
gdk/wayland/gdkselection-wayland.c
gdk/x11/gdkdnd-x11.c
gdk/x11/gdkdrop-x11.c

index 5e0830c15ee1b83076745b9e0bf5fd63cb71d579..1db76f43d36976283f44c9fc8c6851a9c3d9796a 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "config.h"
 
-#include "gdkdndprivate.h"
+#include "gdkdragprivate.h"
 
 #include "gdkinternals.h"
 #include "gdkproperty.h"
index 3362f9aefc6705fe94609c23b5c1e4c1fbaecb3a..a537ed341ffda786ecbbe1396229070938128dfd 100644 (file)
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -44,7 +44,7 @@
 #include <gdk/gdkdevicetool.h>
 #include <gdk/gdkdisplay.h>
 #include <gdk/gdkdisplaymanager.h>
-#include <gdk/gdkdnd.h>
+#include <gdk/gdkdrag.h>
 #include <gdk/gdkdrawcontext.h>
 #include <gdk/gdkdrop.h>
 #include <gdk/gdkenumtypes.h>
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
deleted file mode 100644 (file)
index 8cdd208..0000000
+++ /dev/null
@@ -1,767 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include "config.h"
-
-#include "gdkdndprivate.h"
-#include "gdkdisplay.h"
-#include "gdksurface.h"
-#include "gdkintl.h"
-#include "gdkcontentformats.h"
-#include "gdkcontentprovider.h"
-#include "gdkcontentserializer.h"
-#include "gdkcursor.h"
-#include "gdkenumtypes.h"
-#include "gdkeventsprivate.h"
-
-typedef struct _GdkDragPrivate GdkDragPrivate;
-
-struct _GdkDragPrivate 
-{
-  GdkDisplay *display;
-  GdkDevice *device;
-  GdkContentFormats *formats;
-  GdkDragAction actions;
-  GdkDragAction suggested_action;
-};
-
-static struct {
-  GdkDragAction action;
-  const gchar  *name;
-  GdkCursor    *cursor;
-} drag_cursors[] = {
-  { GDK_ACTION_ASK,     "dnd-ask",  NULL },
-  { GDK_ACTION_COPY,    "dnd-copy", NULL },
-  { GDK_ACTION_MOVE,    "dnd-move", NULL },
-  { GDK_ACTION_LINK,    "dnd-link", NULL },
-  { 0,                  "dnd-none", NULL },
-};
-
-enum {
-  PROP_0,
-  PROP_CONTENT,
-  PROP_DEVICE,
-  PROP_DISPLAY,
-  PROP_FORMATS,
-  N_PROPERTIES
-};
-
-enum {
-  CANCEL,
-  DROP_PERFORMED,
-  DND_FINISHED,
-  ACTION_CHANGED,
-  N_SIGNALS
-};
-
-static GParamSpec *properties[N_PROPERTIES] = { NULL, };
-static guint signals[N_SIGNALS] = { 0 };
-static GList *drags = NULL;
-
-G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
-
-/**
- * SECTION:dnd
- * @title: Drag And Drop
- * @short_description: Functions for controlling drag and drop handling
- *
- * These functions provide a low level interface for drag and drop.
- * The X backend of GDK supports both the Xdnd and Motif drag and drop
- * protocols transparently, the Win32 backend supports the WM_DROPFILES
- * protocol.
- *
- * GTK+ provides a higher level abstraction based on top of these functions,
- * and so they are not normally needed in GTK+ applications.
- * See the [Drag and Drop][gtk3-Drag-and-Drop] section of
- * the GTK+ documentation for more information.
- */
-
-/**
- * GdkDrag:
- *
- * The GdkDrag struct contains only private fields and
- * should not be accessed directly.
- */
-
-/**
- * gdk_drag_get_display:
- * @drag: a #GdkDrag
- *
- * Gets the #GdkDisplay that the drag object was created for.
- *
- * Returns: (transfer none): a #GdkDisplay
- **/
-GdkDisplay *
-gdk_drag_get_display (GdkDrag *drag)
-{
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
-
-  return priv->display;
-}
-
-/**
- * gdk_drag_get_formats:
- * @drag: a #GdkDrag
- *
- * Retrieves the formats supported by this GdkDrag object.
- *
- * Returns: (transfer none): a #GdkContentFormats
- **/
-GdkContentFormats *
-gdk_drag_get_formats (GdkDrag *drag)
-{
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
-
-  return priv->formats;
-}
-
-/**
- * gdk_drag_get_actions:
- * @drag: a #GdkDrag
- *
- * Determines the bitmask of actions proposed by the source if
- * gdk_drag_get_suggested_action() returns %GDK_ACTION_ASK.
- *
- * Returns: the #GdkDragAction flags
- **/
-GdkDragAction
-gdk_drag_get_actions (GdkDrag *drag)
-{
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
-
-  return priv->actions;
-}
-
-/**
- * gdk_drag_get_suggested_action:
- * @drag: a #GdkDrag
- *
- * Determines the suggested drag action of the GdkDrag object.
- *
- * Returns: a #GdkDragAction value
- **/
-GdkDragAction
-gdk_drag_get_suggested_action (GdkDrag *drag)
-{
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
-
-  return priv->suggested_action;
-}
-
-/**
- * gdk_drag_get_selected_action:
- * @drag: a #GdkDrag
- *
- * Determines the action chosen by the drag destination.
- *
- * Returns: a #GdkDragAction value
- **/
-GdkDragAction
-gdk_drag_get_selected_action (GdkDrag *drag)
-{
-  g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
-
-  return drag->action;
-}
-
-/**
- * gdk_drag_get_device:
- * @drag: a #GdkDrag
- *
- * Returns the #GdkDevice associated to the GdkDrag object.
- *
- * Returns: (transfer none): The #GdkDevice associated to @drag.
- **/
-GdkDevice *
-gdk_drag_get_device (GdkDrag *drag)
-{
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
-
-  return priv->device;
-}
-
-static void
-gdk_drag_init (GdkDrag *drag)
-{
-  drags = g_list_prepend (drags, drag);
-}
-
-static void
-gdk_drag_set_property (GObject      *gobject,
-                       guint         prop_id,
-                       const GValue *value,
-                       GParamSpec   *pspec)
-{
-  GdkDrag *drag = GDK_DRAG (gobject);
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  switch (prop_id)
-    {
-    case PROP_CONTENT:
-      drag->content = g_value_dup_object (value);
-      if (drag->content)
-        {
-          g_assert (priv->formats == NULL);
-          priv->formats = gdk_content_provider_ref_formats (drag->content);
-        }
-      break;
-
-    case PROP_DEVICE:
-      priv->device = g_value_dup_object (value);
-      g_assert (priv->device != NULL);
-      priv->display = gdk_device_get_display (priv->device);
-      break;
-
-    case PROP_FORMATS:
-      if (priv->formats)
-        {
-          GdkContentFormats *override = g_value_dup_boxed (value);
-          if (override)
-            {
-              gdk_content_formats_unref (priv->formats);
-              priv->formats = override;
-            }
-        }
-      else
-        {
-          priv->formats = g_value_dup_boxed (value);
-          g_assert (priv->formats != NULL);
-        }
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
-      break;
-    }
-}
-
-static void
-gdk_drag_get_property (GObject    *gobject,
-                       guint       prop_id,
-                       GValue     *value,
-                       GParamSpec *pspec)
-{
-  GdkDrag *drag = GDK_DRAG (gobject);
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  switch (prop_id)
-    {
-    case PROP_CONTENT:
-      g_value_set_object (value, drag->content);
-      break;
-
-    case PROP_DEVICE:
-      g_value_set_object (value, priv->device);
-      break;
-
-    case PROP_DISPLAY:
-      g_value_set_object (value, priv->display);
-      break;
-
-    case PROP_FORMATS:
-      g_value_set_boxed (value, priv->formats);
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
-      break;
-    }
-}
-
-static void
-gdk_drag_finalize (GObject *object)
-{
-  GdkDrag *drag = GDK_DRAG (object);
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  drags = g_list_remove (drags, drag);
-
-  g_clear_object (&drag->content);
-  g_clear_pointer (&priv->formats, gdk_content_formats_unref);
-
-  if (drag->source_surface)
-    g_object_unref (drag->source_surface);
-
-  G_OBJECT_CLASS (gdk_drag_parent_class)->finalize (object);
-}
-
-static void
-gdk_drag_class_init (GdkDragClass *klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-  object_class->get_property = gdk_drag_get_property;
-  object_class->set_property = gdk_drag_set_property;
-  object_class->finalize = gdk_drag_finalize;
-
-  /**
-   * GdkDrag:content:
-   *
-   * The #GdkContentProvider.
-   */
-  properties[PROP_CONTENT] =
-    g_param_spec_object ("content",
-                         "Content",
-                         "The content being dragged",
-                         GDK_TYPE_CONTENT_PROVIDER,
-                         G_PARAM_READWRITE |
-                         G_PARAM_CONSTRUCT_ONLY |
-                         G_PARAM_STATIC_STRINGS |
-                         G_PARAM_EXPLICIT_NOTIFY);
-
-  /**
-   * GdkDrag:device:
-   *
-   * The #GdkDevice that is performing the drag.
-   */
-  properties[PROP_DEVICE] =
-    g_param_spec_object ("device",
-                         "Device",
-                         "The device performing the drag",
-                         GDK_TYPE_DEVICE,
-                         G_PARAM_READWRITE |
-                         G_PARAM_CONSTRUCT_ONLY |
-                         G_PARAM_STATIC_STRINGS |
-                         G_PARAM_EXPLICIT_NOTIFY);
-
-  /**
-   * GdkDrag:display:
-   *
-   * The #GdkDisplay that the drag belongs to.
-   */
-  properties[PROP_DISPLAY] =
-    g_param_spec_object ("display",
-                         "Display",
-                         "Display this drag belongs to",
-                         GDK_TYPE_DISPLAY,
-                         G_PARAM_READABLE |
-                         G_PARAM_STATIC_STRINGS |
-                         G_PARAM_EXPLICIT_NOTIFY);
-
-  /**
-   * GdkDrag:formats:
-   *
-   * The possible formats that the drag can provide its data in.
-   */
-  properties[PROP_FORMATS] =
-    g_param_spec_boxed ("formats",
-                        "Formats",
-                        "The possible formats for data",
-                        GDK_TYPE_CONTENT_FORMATS,
-                        G_PARAM_READWRITE |
-                        G_PARAM_CONSTRUCT_ONLY |
-                        G_PARAM_STATIC_STRINGS |
-                        G_PARAM_EXPLICIT_NOTIFY);
-
-  /**
-   * GdkDrag::cancel:
-   * @drag: The object on which the signal is emitted
-   * @reason: The reason the drag was cancelled
-   *
-   * The drag operation was cancelled.
-   */
-  signals[CANCEL] =
-    g_signal_new (g_intern_static_string ("cancel"),
-                  G_TYPE_FROM_CLASS (object_class),
-                  G_SIGNAL_RUN_LAST,
-                  G_STRUCT_OFFSET (GdkDragClass, cancel),
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__ENUM,
-                  G_TYPE_NONE, 1, GDK_TYPE_DRAG_CANCEL_REASON);
-
-  /**
-   * GdkDrag::drop-performed:
-   * @drag: The object on which the signal is emitted
-   *
-   * The drag operation was performed on an accepting client.
-   */
-  signals[DROP_PERFORMED] =
-    g_signal_new (g_intern_static_string ("drop-performed"),
-                  G_TYPE_FROM_CLASS (object_class),
-                  G_SIGNAL_RUN_LAST,
-                  G_STRUCT_OFFSET (GdkDragClass, drop_performed),
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE, 0);
-
-  /**
-   * GdkDrag::dnd-finished:
-   * @drag: The object on which the signal is emitted
-   *
-   * The drag operation was finished, the destination
-   * finished reading all data. The drag object can now
-   * free all miscellaneous data.
-   */
-  signals[DND_FINISHED] =
-    g_signal_new (g_intern_static_string ("dnd-finished"),
-                  G_TYPE_FROM_CLASS (object_class),
-                  G_SIGNAL_RUN_LAST,
-                  G_STRUCT_OFFSET (GdkDragClass, dnd_finished),
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__VOID,
-                  G_TYPE_NONE, 0);
-
-  /**
-   * GdkDrag::action-changed:
-   * @drag: The object on which the signal is emitted
-   * @action: The action currently chosen
-   *
-   * A new action is being chosen for the drag operation.
-   */
-  signals[ACTION_CHANGED] =
-    g_signal_new (g_intern_static_string ("action-changed"),
-                  G_TYPE_FROM_CLASS (object_class),
-                  G_SIGNAL_RUN_LAST,
-                  G_STRUCT_OFFSET (GdkDragClass, action_changed),
-                  NULL, NULL,
-                  g_cclosure_marshal_VOID__FLAGS,
-                  G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
-
-  g_object_class_install_properties (object_class, N_PROPERTIES, properties);
-}
-
-/*
- * gdk_drag_abort:
- * @drag: a #GdkDrag
- * @time_: the timestamp for this operation
- *
- * Aborts a drag without dropping.
- *
- * This function is called by the drag source.
- */
-void
-gdk_drag_abort (GdkDrag *drag,
-                guint32  time_)
-{
-  g_return_if_fail (GDK_IS_DRAG (drag));
-
-  GDK_DRAG_GET_CLASS (drag)->drag_abort (drag, time_);
-}
-
-/*
- * gdk_drag_drop:
- * @drag: a #GdkDrag
- * @time_: the timestamp for this operation
- *
- * Drops on the current destination.
- *
- * This function is called by the drag source.
- */
-void
-gdk_drag_drop (GdkDrag *drag,
-               guint32  time_)
-{
-  g_return_if_fail (GDK_IS_DRAG (drag));
-
-  GDK_DRAG_GET_CLASS (drag)->drag_drop (drag, time_);
-}
-
-static void
-gdk_drag_write_done (GObject      *content,
-                     GAsyncResult *result,
-                     gpointer      task)
-{
-  GError *error = NULL;
-
-  if (gdk_content_provider_write_mime_type_finish (GDK_CONTENT_PROVIDER (content), result, &error))
-    g_task_return_boolean (task, TRUE);
-  else
-    g_task_return_error (task, error);
-
-  g_object_unref (task);
-}
-
-static void
-gdk_drag_write_serialize_done (GObject      *content,
-                               GAsyncResult *result,
-                               gpointer      task)
-{
-  GError *error = NULL;
-
-  if (gdk_content_serialize_finish (result, &error))
-    g_task_return_boolean (task, TRUE);
-  else
-    g_task_return_error (task, error);
-
-  g_object_unref (task);
-}
-
-void
-gdk_drag_write_async (GdkDrag             *drag,
-                      const char          *mime_type,
-                      GOutputStream       *stream,
-                      int                  io_priority,
-                      GCancellable        *cancellable,
-                      GAsyncReadyCallback  callback,
-                      gpointer             user_data)
-{
-  GdkContentFormats *formats, *mime_formats;
-  GTask *task;
-  GType gtype;
-
-  g_return_if_fail (GDK_IS_DRAG (drag));
-  g_return_if_fail (drag->content);
-  g_return_if_fail (mime_type != NULL);
-  g_return_if_fail (mime_type == g_intern_string (mime_type));
-  g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
-  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
-  g_return_if_fail (callback != NULL);
-
-  task = g_task_new (drag, cancellable, callback, user_data);
-  g_task_set_priority (task, io_priority);
-  g_task_set_source_tag (task, gdk_drag_write_async);
-
-  formats = gdk_content_provider_ref_formats (drag->content);
-  if (gdk_content_formats_contain_mime_type (formats, mime_type))
-    {
-      gdk_content_provider_write_mime_type_async (drag->content,
-                                                  mime_type,
-                                                  stream,
-                                                  io_priority,
-                                                  cancellable,
-                                                  gdk_drag_write_done,
-                                                  task);
-      gdk_content_formats_unref (formats);
-      return;
-    }
-
-  mime_formats = gdk_content_formats_new ((const gchar *[2]) { mime_type, NULL }, 1);
-  mime_formats = gdk_content_formats_union_serialize_gtypes (mime_formats);
-  gtype = gdk_content_formats_match_gtype (formats, mime_formats);
-  if (gtype != G_TYPE_INVALID)
-    {
-      GValue value = G_VALUE_INIT;
-      GError *error = NULL;
-
-      g_assert (gtype != G_TYPE_INVALID);
-      
-      g_value_init (&value, gtype);
-      if (gdk_content_provider_get_value (drag->content, &value, &error))
-        {
-          gdk_content_serialize_async (stream,
-                                       mime_type,
-                                       &value,
-                                       io_priority,
-                                       cancellable,
-                                       gdk_drag_write_serialize_done,
-                                       g_object_ref (task));
-        }
-      else
-        {
-          g_task_return_error (task, error);
-        }
-      
-      g_value_unset (&value);
-    }
-  else
-    {
-      g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
-                               _("No compatible formats to transfer clipboard contents."));
-    }
-
-  gdk_content_formats_unref (mime_formats);
-  gdk_content_formats_unref (formats);
-  g_object_unref (task);
-}
-
-gboolean
-gdk_drag_write_finish (GdkDrag       *drag,
-                       GAsyncResult  *result,
-                       GError       **error)
-{
-  g_return_val_if_fail (g_task_is_valid (result, drag), FALSE);
-  g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_drag_write_async, FALSE);
-
-  return g_task_propagate_boolean (G_TASK (result), error); 
-}
-
-void
-gdk_drag_set_actions (GdkDrag       *drag,
-                      GdkDragAction  actions,
-                      GdkDragAction  suggested_action)
-{
-  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
-
-  priv->actions = actions;
-  priv->suggested_action = suggested_action;
-}
-
-/**
- * gdk_drag_get_drag_surface:
- * @drag: a #GdkDrag
- *
- * Returns the surface on which the drag icon should be rendered
- * during the drag operation. Note that the surface may not be
- * available until the drag operation has begun. GDK will move
- * the surface in accordance with the ongoing drag operation.
- * The surface is owned by @drag and will be destroyed when
- * the drag operation is over.
- *
- * Returns: (nullable) (transfer none): the drag surface, or %NULL
- */
-GdkSurface *
-gdk_drag_get_drag_surface (GdkDrag *drag)
-{
-  g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
-
-  if (GDK_DRAG_GET_CLASS (drag)->get_drag_surface)
-    return GDK_DRAG_GET_CLASS (drag)->get_drag_surface (drag);
-
-  return NULL;
-}
-
-/**
- * gdk_drag_set_hotspot:
- * @drag: a #GdkDrag
- * @hot_x: x coordinate of the drag surface hotspot
- * @hot_y: y coordinate of the drag surface hotspot
- *
- * Sets the position of the drag surface that will be kept
- * under the cursor hotspot. Initially, the hotspot is at the
- * top left corner of the drag surface.
- */
-void
-gdk_drag_set_hotspot (GdkDrag *drag,
-                      gint     hot_x,
-                      gint     hot_y)
-{
-  g_return_if_fail (GDK_IS_DRAG (drag));
-
-  if (GDK_DRAG_GET_CLASS (drag)->set_hotspot)
-    GDK_DRAG_GET_CLASS (drag)->set_hotspot (drag, hot_x, hot_y);
-}
-
-/**
- * gdk_drag_drop_done:
- * @drag: a #GdkDrag
- * @success: whether the drag was ultimatively successful
- *
- * Inform GDK if the drop ended successfully. Passing %FALSE
- * for @success may trigger a drag cancellation animation.
- *
- * This function is called by the drag source, and should
- * be the last call before dropping the reference to the
- * @drag.
- *
- * The #GdkDrag will only take the first gdk_drag_drop_done()
- * call as effective, if this function is called multiple times,
- * all subsequent calls will be ignored.
- */
-void
-gdk_drag_drop_done (GdkDrag  *drag,
-                    gboolean  success)
-{
-  g_return_if_fail (GDK_IS_DRAG (drag));
-
-  if (drag->drop_done)
-    return;
-
-  drag->drop_done = TRUE;
-
-  if (GDK_DRAG_GET_CLASS (drag)->drop_done)
-    GDK_DRAG_GET_CLASS (drag)->drop_done (drag, success);
-}
-
-void
-gdk_drag_set_cursor (GdkDrag   *drag,
-                     GdkCursor *cursor)
-{
-  g_return_if_fail (GDK_IS_DRAG (drag));
-
-  if (GDK_DRAG_GET_CLASS (drag)->set_cursor)
-    GDK_DRAG_GET_CLASS (drag)->set_cursor (drag, cursor);
-}
-
-void
-gdk_drag_cancel (GdkDrag             *drag,
-                 GdkDragCancelReason  reason)
-{
-  g_return_if_fail (GDK_IS_DRAG (drag));
-
-  g_signal_emit (drag, signals[CANCEL], 0, reason);
-}
-
-gboolean
-gdk_drag_handle_source_event (GdkEvent *event)
-{
-  GdkDrag *drag;
-  GList *l;
-
-  for (l = drags; l; l = l->next)
-    {
-      drag = l->data;
-
-      if (!GDK_DRAG_GET_CLASS (drag)->handle_event)
-        continue;
-
-      if (GDK_DRAG_GET_CLASS (drag)->handle_event (drag, event))
-        return TRUE;
-    }
-
-  return FALSE;
-}
-
-GdkCursor *
-gdk_drag_get_cursor (GdkDrag       *drag,
-                     GdkDragAction  action)
-{
-  gint i;
-
-  for (i = 0 ; i < G_N_ELEMENTS (drag_cursors) - 1; i++)
-    if (drag_cursors[i].action == action)
-      break;
-
-  if (drag_cursors[i].cursor == NULL)
-    drag_cursors[i].cursor = gdk_cursor_new_from_name (drag_cursors[i].name, NULL);
-                                                       
-  return drag_cursors[i].cursor;
-}
-
-/**
- * gdk_drag_action_is_unique:
- * @action: a #GdkDragAction
- *
- * Checks if @action represents a single action or if it
- * includes multiple flags that can be selected from.
- *
- * When @action is 0 - ie no action was given, %TRUE
- * is returned.
- *
- * Returns: %TRUE if exactly one action was given
- **/
-gboolean
-gdk_drag_action_is_unique (GdkDragAction action)
-{
-  return (action & (action - 1)) == 0;
-}
diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h
deleted file mode 100644 (file)
index dd24c72..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GDK_DND_H__
-#define __GDK_DND_H__
-
-#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
-#error "Only <gdk/gdk.h> can be included directly."
-#endif
-
-#include <gdk/gdktypes.h>
-#include <gdk/gdkdevice.h>
-#include <gdk/gdkevents.h>
-
-G_BEGIN_DECLS
-
-#define GDK_TYPE_DRAG              (gdk_drag_get_type ())
-#define GDK_DRAG(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAG, GdkDrag))
-#define GDK_IS_DRAG(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAG))
-
-/**
- * GdkDragCancelReason:
- * @GDK_DRAG_CANCEL_NO_TARGET: There is no suitable drop target.
- * @GDK_DRAG_CANCEL_USER_CANCELLED: Drag cancelled by the user
- * @GDK_DRAG_CANCEL_ERROR: Unspecified error.
- *
- * Used in #GdkDrag to the reason of a cancelled DND operation.
- */
-typedef enum {
-  GDK_DRAG_CANCEL_NO_TARGET,
-  GDK_DRAG_CANCEL_USER_CANCELLED,
-  GDK_DRAG_CANCEL_ERROR
-} GdkDragCancelReason;
-
-GDK_AVAILABLE_IN_ALL
-GType            gdk_drag_get_type             (void) G_GNUC_CONST;
-
-GDK_AVAILABLE_IN_ALL
-GdkDisplay *     gdk_drag_get_display          (GdkDrag *drag);
-GDK_AVAILABLE_IN_ALL
-GdkDevice *      gdk_drag_get_device           (GdkDrag *drag);
-
-GDK_AVAILABLE_IN_ALL
-GdkContentFormats *gdk_drag_get_formats        (GdkDrag *drag);
-GDK_AVAILABLE_IN_ALL
-GdkDragAction    gdk_drag_get_actions          (GdkDrag *drag);
-GDK_AVAILABLE_IN_ALL
-GdkDragAction    gdk_drag_get_suggested_action (GdkDrag *drag);
-GDK_AVAILABLE_IN_ALL
-GdkDragAction    gdk_drag_get_selected_action  (GdkDrag *drag);
-
-GDK_AVAILABLE_IN_ALL
-gboolean         gdk_drag_action_is_unique     (GdkDragAction   action);
-
-GDK_AVAILABLE_IN_ALL
-GdkDrag *        gdk_drag_begin                (GdkSurface         *surface,
-                                                GdkDevice          *device,
-                                                GdkContentProvider *content,
-                                                GdkDragAction       actions,
-                                                gint                dx,
-                                                gint                dy);
-
-GDK_AVAILABLE_IN_ALL
-void            gdk_drag_drop_done   (GdkDrag  *drag,
-                                      gboolean  success);
-
-GDK_AVAILABLE_IN_ALL
-GdkSurface      *gdk_drag_get_drag_surface (GdkDrag *drag);
-
-GDK_AVAILABLE_IN_ALL
-void            gdk_drag_set_hotspot (GdkDrag *drag,
-                                      gint     hot_x,
-                                      gint     hot_y);
-
-G_END_DECLS
-
-#endif /* __GDK_DND_H__ */
diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h
deleted file mode 100644 (file)
index b3f75ea..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/* GDK - The GIMP Drawing Kit
- * Copyright (C) 2010, Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GDK_DND_PRIVATE_H__
-#define __GDK_DND_PRIVATE_H__
-
-#include "gdkdnd.h"
-
-G_BEGIN_DECLS
-
-
-#define GDK_DRAG_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAG, GdkDragClass))
-#define GDK_IS_DRAG_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAG))
-#define GDK_DRAG_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAG, GdkDragClass))
-
-typedef struct _GdkDragClass GdkDragClass;
-
-
-struct _GdkDragClass {
-  GObjectClass parent_class;
-
-  void        (*drag_abort)    (GdkDrag  *drag,
-                                guint32          time_);
-  void        (*drag_drop)     (GdkDrag  *drag,
-                                guint32          time_);
-  GdkSurface*  (*get_drag_surface) (GdkDrag *drag);
-  void        (*set_hotspot)   (GdkDrag  *drag,
-                                gint             hot_x,
-                                gint             hot_y);
-  void        (*drop_done)     (GdkDrag   *drag,
-                                gboolean          success);
-
-  void        (*set_cursor)     (GdkDrag  *drag,
-                                 GdkCursor       *cursor);
-  void        (*cancel)         (GdkDrag      *drag,
-                                 GdkDragCancelReason  reason);
-  void        (*drop_performed) (GdkDrag  *drag,
-                                 guint32          time);
-  void        (*dnd_finished)   (GdkDrag  *drag);
-
-  gboolean    (*handle_event)   (GdkDrag  *drag,
-                                 const GdkEvent  *event);
-  void        (*action_changed) (GdkDrag  *drag,
-                                 GdkDragAction    action);
-};
-
-struct _GdkDrag {
-  GObject parent_instance;
-
-  /*< private >*/
-  GdkSurface *source_surface;
-  GdkSurface *drag_surface;
-
-  GdkContentProvider *content;
-  GdkDragAction action;
-
-  guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
-};
-
-void     gdk_drag_set_cursor          (GdkDrag        *drag,
-                                       GdkCursor      *cursor);
-void     gdk_drag_set_actions         (GdkDrag        *drag,
-                                       GdkDragAction   actions,
-                                       GdkDragAction   suggested_action);
-
-void     gdk_drag_cancel              (GdkDrag        *drag,
-                                       GdkDragCancelReason  reason);
-gboolean gdk_drag_handle_source_event (GdkEvent       *event);
-GdkCursor * gdk_drag_get_cursor       (GdkDrag        *drag,
-                                       GdkDragAction   action);
-
-void     gdk_drag_abort               (GdkDrag        *drag,
-                                       guint32         time_);
-void     gdk_drag_drop                (GdkDrag        *drag,
-                                       guint32         time_);
-
-void     gdk_drag_write_async         (GdkDrag             *drag,
-                                       const char          *mime_type,
-                                       GOutputStream       *stream,
-                                       int                  io_priority,
-                                       GCancellable        *cancellable,
-                                       GAsyncReadyCallback  callback,
-                                       gpointer             user_data);
-gboolean gdk_drag_write_finish        (GdkDrag             *drag,
-                                       GAsyncResult        *result,
-                                       GError             **error);
-
-
-G_END_DECLS
-
-#endif
diff --git a/gdk/gdkdrag.c b/gdk/gdkdrag.c
new file mode 100644 (file)
index 0000000..2e8efb8
--- /dev/null
@@ -0,0 +1,767 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ */
+
+#include "config.h"
+
+#include "gdkdragprivate.h"
+#include "gdkdisplay.h"
+#include "gdksurface.h"
+#include "gdkintl.h"
+#include "gdkcontentformats.h"
+#include "gdkcontentprovider.h"
+#include "gdkcontentserializer.h"
+#include "gdkcursor.h"
+#include "gdkenumtypes.h"
+#include "gdkeventsprivate.h"
+
+typedef struct _GdkDragPrivate GdkDragPrivate;
+
+struct _GdkDragPrivate 
+{
+  GdkDisplay *display;
+  GdkDevice *device;
+  GdkContentFormats *formats;
+  GdkDragAction actions;
+  GdkDragAction suggested_action;
+};
+
+static struct {
+  GdkDragAction action;
+  const gchar  *name;
+  GdkCursor    *cursor;
+} drag_cursors[] = {
+  { GDK_ACTION_ASK,     "dnd-ask",  NULL },
+  { GDK_ACTION_COPY,    "dnd-copy", NULL },
+  { GDK_ACTION_MOVE,    "dnd-move", NULL },
+  { GDK_ACTION_LINK,    "dnd-link", NULL },
+  { 0,                  "dnd-none", NULL },
+};
+
+enum {
+  PROP_0,
+  PROP_CONTENT,
+  PROP_DEVICE,
+  PROP_DISPLAY,
+  PROP_FORMATS,
+  N_PROPERTIES
+};
+
+enum {
+  CANCEL,
+  DROP_PERFORMED,
+  DND_FINISHED,
+  ACTION_CHANGED,
+  N_SIGNALS
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+static guint signals[N_SIGNALS] = { 0 };
+static GList *drags = NULL;
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
+
+/**
+ * SECTION:dnd
+ * @title: Drag And Drop
+ * @short_description: Functions for controlling drag and drop handling
+ *
+ * These functions provide a low level interface for drag and drop.
+ * The X backend of GDK supports both the Xdnd and Motif drag and drop
+ * protocols transparently, the Win32 backend supports the WM_DROPFILES
+ * protocol.
+ *
+ * GTK+ provides a higher level abstraction based on top of these functions,
+ * and so they are not normally needed in GTK+ applications.
+ * See the [Drag and Drop][gtk3-Drag-and-Drop] section of
+ * the GTK+ documentation for more information.
+ */
+
+/**
+ * GdkDrag:
+ *
+ * The GdkDrag struct contains only private fields and
+ * should not be accessed directly.
+ */
+
+/**
+ * gdk_drag_get_display:
+ * @drag: a #GdkDrag
+ *
+ * Gets the #GdkDisplay that the drag object was created for.
+ *
+ * Returns: (transfer none): a #GdkDisplay
+ **/
+GdkDisplay *
+gdk_drag_get_display (GdkDrag *drag)
+{
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
+
+  return priv->display;
+}
+
+/**
+ * gdk_drag_get_formats:
+ * @drag: a #GdkDrag
+ *
+ * Retrieves the formats supported by this GdkDrag object.
+ *
+ * Returns: (transfer none): a #GdkContentFormats
+ **/
+GdkContentFormats *
+gdk_drag_get_formats (GdkDrag *drag)
+{
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
+
+  return priv->formats;
+}
+
+/**
+ * gdk_drag_get_actions:
+ * @drag: a #GdkDrag
+ *
+ * Determines the bitmask of actions proposed by the source if
+ * gdk_drag_get_suggested_action() returns %GDK_ACTION_ASK.
+ *
+ * Returns: the #GdkDragAction flags
+ **/
+GdkDragAction
+gdk_drag_get_actions (GdkDrag *drag)
+{
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
+
+  return priv->actions;
+}
+
+/**
+ * gdk_drag_get_suggested_action:
+ * @drag: a #GdkDrag
+ *
+ * Determines the suggested drag action of the GdkDrag object.
+ *
+ * Returns: a #GdkDragAction value
+ **/
+GdkDragAction
+gdk_drag_get_suggested_action (GdkDrag *drag)
+{
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
+
+  return priv->suggested_action;
+}
+
+/**
+ * gdk_drag_get_selected_action:
+ * @drag: a #GdkDrag
+ *
+ * Determines the action chosen by the drag destination.
+ *
+ * Returns: a #GdkDragAction value
+ **/
+GdkDragAction
+gdk_drag_get_selected_action (GdkDrag *drag)
+{
+  g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
+
+  return drag->action;
+}
+
+/**
+ * gdk_drag_get_device:
+ * @drag: a #GdkDrag
+ *
+ * Returns the #GdkDevice associated to the GdkDrag object.
+ *
+ * Returns: (transfer none): The #GdkDevice associated to @drag.
+ **/
+GdkDevice *
+gdk_drag_get_device (GdkDrag *drag)
+{
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
+
+  return priv->device;
+}
+
+static void
+gdk_drag_init (GdkDrag *drag)
+{
+  drags = g_list_prepend (drags, drag);
+}
+
+static void
+gdk_drag_set_property (GObject      *gobject,
+                       guint         prop_id,
+                       const GValue *value,
+                       GParamSpec   *pspec)
+{
+  GdkDrag *drag = GDK_DRAG (gobject);
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  switch (prop_id)
+    {
+    case PROP_CONTENT:
+      drag->content = g_value_dup_object (value);
+      if (drag->content)
+        {
+          g_assert (priv->formats == NULL);
+          priv->formats = gdk_content_provider_ref_formats (drag->content);
+        }
+      break;
+
+    case PROP_DEVICE:
+      priv->device = g_value_dup_object (value);
+      g_assert (priv->device != NULL);
+      priv->display = gdk_device_get_display (priv->device);
+      break;
+
+    case PROP_FORMATS:
+      if (priv->formats)
+        {
+          GdkContentFormats *override = g_value_dup_boxed (value);
+          if (override)
+            {
+              gdk_content_formats_unref (priv->formats);
+              priv->formats = override;
+            }
+        }
+      else
+        {
+          priv->formats = g_value_dup_boxed (value);
+          g_assert (priv->formats != NULL);
+        }
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+gdk_drag_get_property (GObject    *gobject,
+                       guint       prop_id,
+                       GValue     *value,
+                       GParamSpec *pspec)
+{
+  GdkDrag *drag = GDK_DRAG (gobject);
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  switch (prop_id)
+    {
+    case PROP_CONTENT:
+      g_value_set_object (value, drag->content);
+      break;
+
+    case PROP_DEVICE:
+      g_value_set_object (value, priv->device);
+      break;
+
+    case PROP_DISPLAY:
+      g_value_set_object (value, priv->display);
+      break;
+
+    case PROP_FORMATS:
+      g_value_set_boxed (value, priv->formats);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+gdk_drag_finalize (GObject *object)
+{
+  GdkDrag *drag = GDK_DRAG (object);
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  drags = g_list_remove (drags, drag);
+
+  g_clear_object (&drag->content);
+  g_clear_pointer (&priv->formats, gdk_content_formats_unref);
+
+  if (drag->source_surface)
+    g_object_unref (drag->source_surface);
+
+  G_OBJECT_CLASS (gdk_drag_parent_class)->finalize (object);
+}
+
+static void
+gdk_drag_class_init (GdkDragClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->get_property = gdk_drag_get_property;
+  object_class->set_property = gdk_drag_set_property;
+  object_class->finalize = gdk_drag_finalize;
+
+  /**
+   * GdkDrag:content:
+   *
+   * The #GdkContentProvider.
+   */
+  properties[PROP_CONTENT] =
+    g_param_spec_object ("content",
+                         "Content",
+                         "The content being dragged",
+                         GDK_TYPE_CONTENT_PROVIDER,
+                         G_PARAM_READWRITE |
+                         G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_STATIC_STRINGS |
+                         G_PARAM_EXPLICIT_NOTIFY);
+
+  /**
+   * GdkDrag:device:
+   *
+   * The #GdkDevice that is performing the drag.
+   */
+  properties[PROP_DEVICE] =
+    g_param_spec_object ("device",
+                         "Device",
+                         "The device performing the drag",
+                         GDK_TYPE_DEVICE,
+                         G_PARAM_READWRITE |
+                         G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_STATIC_STRINGS |
+                         G_PARAM_EXPLICIT_NOTIFY);
+
+  /**
+   * GdkDrag:display:
+   *
+   * The #GdkDisplay that the drag belongs to.
+   */
+  properties[PROP_DISPLAY] =
+    g_param_spec_object ("display",
+                         "Display",
+                         "Display this drag belongs to",
+                         GDK_TYPE_DISPLAY,
+                         G_PARAM_READABLE |
+                         G_PARAM_STATIC_STRINGS |
+                         G_PARAM_EXPLICIT_NOTIFY);
+
+  /**
+   * GdkDrag:formats:
+   *
+   * The possible formats that the drag can provide its data in.
+   */
+  properties[PROP_FORMATS] =
+    g_param_spec_boxed ("formats",
+                        "Formats",
+                        "The possible formats for data",
+                        GDK_TYPE_CONTENT_FORMATS,
+                        G_PARAM_READWRITE |
+                        G_PARAM_CONSTRUCT_ONLY |
+                        G_PARAM_STATIC_STRINGS |
+                        G_PARAM_EXPLICIT_NOTIFY);
+
+  /**
+   * GdkDrag::cancel:
+   * @drag: The object on which the signal is emitted
+   * @reason: The reason the drag was cancelled
+   *
+   * The drag operation was cancelled.
+   */
+  signals[CANCEL] =
+    g_signal_new (g_intern_static_string ("cancel"),
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GdkDragClass, cancel),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__ENUM,
+                  G_TYPE_NONE, 1, GDK_TYPE_DRAG_CANCEL_REASON);
+
+  /**
+   * GdkDrag::drop-performed:
+   * @drag: The object on which the signal is emitted
+   *
+   * The drag operation was performed on an accepting client.
+   */
+  signals[DROP_PERFORMED] =
+    g_signal_new (g_intern_static_string ("drop-performed"),
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GdkDragClass, drop_performed),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+
+  /**
+   * GdkDrag::dnd-finished:
+   * @drag: The object on which the signal is emitted
+   *
+   * The drag operation was finished, the destination
+   * finished reading all data. The drag object can now
+   * free all miscellaneous data.
+   */
+  signals[DND_FINISHED] =
+    g_signal_new (g_intern_static_string ("dnd-finished"),
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GdkDragClass, dnd_finished),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+
+  /**
+   * GdkDrag::action-changed:
+   * @drag: The object on which the signal is emitted
+   * @action: The action currently chosen
+   *
+   * A new action is being chosen for the drag operation.
+   */
+  signals[ACTION_CHANGED] =
+    g_signal_new (g_intern_static_string ("action-changed"),
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GdkDragClass, action_changed),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__FLAGS,
+                  G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
+
+  g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+/*
+ * gdk_drag_abort:
+ * @drag: a #GdkDrag
+ * @time_: the timestamp for this operation
+ *
+ * Aborts a drag without dropping.
+ *
+ * This function is called by the drag source.
+ */
+void
+gdk_drag_abort (GdkDrag *drag,
+                guint32  time_)
+{
+  g_return_if_fail (GDK_IS_DRAG (drag));
+
+  GDK_DRAG_GET_CLASS (drag)->drag_abort (drag, time_);
+}
+
+/*
+ * gdk_drag_drop:
+ * @drag: a #GdkDrag
+ * @time_: the timestamp for this operation
+ *
+ * Drops on the current destination.
+ *
+ * This function is called by the drag source.
+ */
+void
+gdk_drag_drop (GdkDrag *drag,
+               guint32  time_)
+{
+  g_return_if_fail (GDK_IS_DRAG (drag));
+
+  GDK_DRAG_GET_CLASS (drag)->drag_drop (drag, time_);
+}
+
+static void
+gdk_drag_write_done (GObject      *content,
+                     GAsyncResult *result,
+                     gpointer      task)
+{
+  GError *error = NULL;
+
+  if (gdk_content_provider_write_mime_type_finish (GDK_CONTENT_PROVIDER (content), result, &error))
+    g_task_return_boolean (task, TRUE);
+  else
+    g_task_return_error (task, error);
+
+  g_object_unref (task);
+}
+
+static void
+gdk_drag_write_serialize_done (GObject      *content,
+                               GAsyncResult *result,
+                               gpointer      task)
+{
+  GError *error = NULL;
+
+  if (gdk_content_serialize_finish (result, &error))
+    g_task_return_boolean (task, TRUE);
+  else
+    g_task_return_error (task, error);
+
+  g_object_unref (task);
+}
+
+void
+gdk_drag_write_async (GdkDrag             *drag,
+                      const char          *mime_type,
+                      GOutputStream       *stream,
+                      int                  io_priority,
+                      GCancellable        *cancellable,
+                      GAsyncReadyCallback  callback,
+                      gpointer             user_data)
+{
+  GdkContentFormats *formats, *mime_formats;
+  GTask *task;
+  GType gtype;
+
+  g_return_if_fail (GDK_IS_DRAG (drag));
+  g_return_if_fail (drag->content);
+  g_return_if_fail (mime_type != NULL);
+  g_return_if_fail (mime_type == g_intern_string (mime_type));
+  g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
+  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+  g_return_if_fail (callback != NULL);
+
+  task = g_task_new (drag, cancellable, callback, user_data);
+  g_task_set_priority (task, io_priority);
+  g_task_set_source_tag (task, gdk_drag_write_async);
+
+  formats = gdk_content_provider_ref_formats (drag->content);
+  if (gdk_content_formats_contain_mime_type (formats, mime_type))
+    {
+      gdk_content_provider_write_mime_type_async (drag->content,
+                                                  mime_type,
+                                                  stream,
+                                                  io_priority,
+                                                  cancellable,
+                                                  gdk_drag_write_done,
+                                                  task);
+      gdk_content_formats_unref (formats);
+      return;
+    }
+
+  mime_formats = gdk_content_formats_new ((const gchar *[2]) { mime_type, NULL }, 1);
+  mime_formats = gdk_content_formats_union_serialize_gtypes (mime_formats);
+  gtype = gdk_content_formats_match_gtype (formats, mime_formats);
+  if (gtype != G_TYPE_INVALID)
+    {
+      GValue value = G_VALUE_INIT;
+      GError *error = NULL;
+
+      g_assert (gtype != G_TYPE_INVALID);
+      
+      g_value_init (&value, gtype);
+      if (gdk_content_provider_get_value (drag->content, &value, &error))
+        {
+          gdk_content_serialize_async (stream,
+                                       mime_type,
+                                       &value,
+                                       io_priority,
+                                       cancellable,
+                                       gdk_drag_write_serialize_done,
+                                       g_object_ref (task));
+        }
+      else
+        {
+          g_task_return_error (task, error);
+        }
+      
+      g_value_unset (&value);
+    }
+  else
+    {
+      g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+                               _("No compatible formats to transfer clipboard contents."));
+    }
+
+  gdk_content_formats_unref (mime_formats);
+  gdk_content_formats_unref (formats);
+  g_object_unref (task);
+}
+
+gboolean
+gdk_drag_write_finish (GdkDrag       *drag,
+                       GAsyncResult  *result,
+                       GError       **error)
+{
+  g_return_val_if_fail (g_task_is_valid (result, drag), FALSE);
+  g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_drag_write_async, FALSE);
+
+  return g_task_propagate_boolean (G_TASK (result), error); 
+}
+
+void
+gdk_drag_set_actions (GdkDrag       *drag,
+                      GdkDragAction  actions,
+                      GdkDragAction  suggested_action)
+{
+  GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
+
+  priv->actions = actions;
+  priv->suggested_action = suggested_action;
+}
+
+/**
+ * gdk_drag_get_drag_surface:
+ * @drag: a #GdkDrag
+ *
+ * Returns the surface on which the drag icon should be rendered
+ * during the drag operation. Note that the surface may not be
+ * available until the drag operation has begun. GDK will move
+ * the surface in accordance with the ongoing drag operation.
+ * The surface is owned by @drag and will be destroyed when
+ * the drag operation is over.
+ *
+ * Returns: (nullable) (transfer none): the drag surface, or %NULL
+ */
+GdkSurface *
+gdk_drag_get_drag_surface (GdkDrag *drag)
+{
+  g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
+
+  if (GDK_DRAG_GET_CLASS (drag)->get_drag_surface)
+    return GDK_DRAG_GET_CLASS (drag)->get_drag_surface (drag);
+
+  return NULL;
+}
+
+/**
+ * gdk_drag_set_hotspot:
+ * @drag: a #GdkDrag
+ * @hot_x: x coordinate of the drag surface hotspot
+ * @hot_y: y coordinate of the drag surface hotspot
+ *
+ * Sets the position of the drag surface that will be kept
+ * under the cursor hotspot. Initially, the hotspot is at the
+ * top left corner of the drag surface.
+ */
+void
+gdk_drag_set_hotspot (GdkDrag *drag,
+                      gint     hot_x,
+                      gint     hot_y)
+{
+  g_return_if_fail (GDK_IS_DRAG (drag));
+
+  if (GDK_DRAG_GET_CLASS (drag)->set_hotspot)
+    GDK_DRAG_GET_CLASS (drag)->set_hotspot (drag, hot_x, hot_y);
+}
+
+/**
+ * gdk_drag_drop_done:
+ * @drag: a #GdkDrag
+ * @success: whether the drag was ultimatively successful
+ *
+ * Inform GDK if the drop ended successfully. Passing %FALSE
+ * for @success may trigger a drag cancellation animation.
+ *
+ * This function is called by the drag source, and should
+ * be the last call before dropping the reference to the
+ * @drag.
+ *
+ * The #GdkDrag will only take the first gdk_drag_drop_done()
+ * call as effective, if this function is called multiple times,
+ * all subsequent calls will be ignored.
+ */
+void
+gdk_drag_drop_done (GdkDrag  *drag,
+                    gboolean  success)
+{
+  g_return_if_fail (GDK_IS_DRAG (drag));
+
+  if (drag->drop_done)
+    return;
+
+  drag->drop_done = TRUE;
+
+  if (GDK_DRAG_GET_CLASS (drag)->drop_done)
+    GDK_DRAG_GET_CLASS (drag)->drop_done (drag, success);
+}
+
+void
+gdk_drag_set_cursor (GdkDrag   *drag,
+                     GdkCursor *cursor)
+{
+  g_return_if_fail (GDK_IS_DRAG (drag));
+
+  if (GDK_DRAG_GET_CLASS (drag)->set_cursor)
+    GDK_DRAG_GET_CLASS (drag)->set_cursor (drag, cursor);
+}
+
+void
+gdk_drag_cancel (GdkDrag             *drag,
+                 GdkDragCancelReason  reason)
+{
+  g_return_if_fail (GDK_IS_DRAG (drag));
+
+  g_signal_emit (drag, signals[CANCEL], 0, reason);
+}
+
+gboolean
+gdk_drag_handle_source_event (GdkEvent *event)
+{
+  GdkDrag *drag;
+  GList *l;
+
+  for (l = drags; l; l = l->next)
+    {
+      drag = l->data;
+
+      if (!GDK_DRAG_GET_CLASS (drag)->handle_event)
+        continue;
+
+      if (GDK_DRAG_GET_CLASS (drag)->handle_event (drag, event))
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
+GdkCursor *
+gdk_drag_get_cursor (GdkDrag       *drag,
+                     GdkDragAction  action)
+{
+  gint i;
+
+  for (i = 0 ; i < G_N_ELEMENTS (drag_cursors) - 1; i++)
+    if (drag_cursors[i].action == action)
+      break;
+
+  if (drag_cursors[i].cursor == NULL)
+    drag_cursors[i].cursor = gdk_cursor_new_from_name (drag_cursors[i].name, NULL);
+                                                       
+  return drag_cursors[i].cursor;
+}
+
+/**
+ * gdk_drag_action_is_unique:
+ * @action: a #GdkDragAction
+ *
+ * Checks if @action represents a single action or if it
+ * includes multiple flags that can be selected from.
+ *
+ * When @action is 0 - ie no action was given, %TRUE
+ * is returned.
+ *
+ * Returns: %TRUE if exactly one action was given
+ **/
+gboolean
+gdk_drag_action_is_unique (GdkDragAction action)
+{
+  return (action & (action - 1)) == 0;
+}
diff --git a/gdk/gdkdrag.h b/gdk/gdkdrag.h
new file mode 100644 (file)
index 0000000..dd24c72
--- /dev/null
@@ -0,0 +1,98 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GDK_DND_H__
+#define __GDK_DND_H__
+
+#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#include <gdk/gdktypes.h>
+#include <gdk/gdkdevice.h>
+#include <gdk/gdkevents.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_DRAG              (gdk_drag_get_type ())
+#define GDK_DRAG(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAG, GdkDrag))
+#define GDK_IS_DRAG(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAG))
+
+/**
+ * GdkDragCancelReason:
+ * @GDK_DRAG_CANCEL_NO_TARGET: There is no suitable drop target.
+ * @GDK_DRAG_CANCEL_USER_CANCELLED: Drag cancelled by the user
+ * @GDK_DRAG_CANCEL_ERROR: Unspecified error.
+ *
+ * Used in #GdkDrag to the reason of a cancelled DND operation.
+ */
+typedef enum {
+  GDK_DRAG_CANCEL_NO_TARGET,
+  GDK_DRAG_CANCEL_USER_CANCELLED,
+  GDK_DRAG_CANCEL_ERROR
+} GdkDragCancelReason;
+
+GDK_AVAILABLE_IN_ALL
+GType            gdk_drag_get_type             (void) G_GNUC_CONST;
+
+GDK_AVAILABLE_IN_ALL
+GdkDisplay *     gdk_drag_get_display          (GdkDrag *drag);
+GDK_AVAILABLE_IN_ALL
+GdkDevice *      gdk_drag_get_device           (GdkDrag *drag);
+
+GDK_AVAILABLE_IN_ALL
+GdkContentFormats *gdk_drag_get_formats        (GdkDrag *drag);
+GDK_AVAILABLE_IN_ALL
+GdkDragAction    gdk_drag_get_actions          (GdkDrag *drag);
+GDK_AVAILABLE_IN_ALL
+GdkDragAction    gdk_drag_get_suggested_action (GdkDrag *drag);
+GDK_AVAILABLE_IN_ALL
+GdkDragAction    gdk_drag_get_selected_action  (GdkDrag *drag);
+
+GDK_AVAILABLE_IN_ALL
+gboolean         gdk_drag_action_is_unique     (GdkDragAction   action);
+
+GDK_AVAILABLE_IN_ALL
+GdkDrag *        gdk_drag_begin                (GdkSurface         *surface,
+                                                GdkDevice          *device,
+                                                GdkContentProvider *content,
+                                                GdkDragAction       actions,
+                                                gint                dx,
+                                                gint                dy);
+
+GDK_AVAILABLE_IN_ALL
+void            gdk_drag_drop_done   (GdkDrag  *drag,
+                                      gboolean  success);
+
+GDK_AVAILABLE_IN_ALL
+GdkSurface      *gdk_drag_get_drag_surface (GdkDrag *drag);
+
+GDK_AVAILABLE_IN_ALL
+void            gdk_drag_set_hotspot (GdkDrag *drag,
+                                      gint     hot_x,
+                                      gint     hot_y);
+
+G_END_DECLS
+
+#endif /* __GDK_DND_H__ */
diff --git a/gdk/gdkdragprivate.h b/gdk/gdkdragprivate.h
new file mode 100644 (file)
index 0000000..01a87ef
--- /dev/null
@@ -0,0 +1,105 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2010, Red Hat, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_DND_PRIVATE_H__
+#define __GDK_DND_PRIVATE_H__
+
+#include "gdkdrag.h"
+
+G_BEGIN_DECLS
+
+
+#define GDK_DRAG_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAG, GdkDragClass))
+#define GDK_IS_DRAG_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAG))
+#define GDK_DRAG_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAG, GdkDragClass))
+
+typedef struct _GdkDragClass GdkDragClass;
+
+
+struct _GdkDragClass {
+  GObjectClass parent_class;
+
+  void        (*drag_abort)    (GdkDrag  *drag,
+                                guint32          time_);
+  void        (*drag_drop)     (GdkDrag  *drag,
+                                guint32          time_);
+  GdkSurface*  (*get_drag_surface) (GdkDrag *drag);
+  void        (*set_hotspot)   (GdkDrag  *drag,
+                                gint             hot_x,
+                                gint             hot_y);
+  void        (*drop_done)     (GdkDrag   *drag,
+                                gboolean          success);
+
+  void        (*set_cursor)     (GdkDrag  *drag,
+                                 GdkCursor       *cursor);
+  void        (*cancel)         (GdkDrag      *drag,
+                                 GdkDragCancelReason  reason);
+  void        (*drop_performed) (GdkDrag  *drag,
+                                 guint32          time);
+  void        (*dnd_finished)   (GdkDrag  *drag);
+
+  gboolean    (*handle_event)   (GdkDrag  *drag,
+                                 const GdkEvent  *event);
+  void        (*action_changed) (GdkDrag  *drag,
+                                 GdkDragAction    action);
+};
+
+struct _GdkDrag {
+  GObject parent_instance;
+
+  /*< private >*/
+  GdkSurface *source_surface;
+  GdkSurface *drag_surface;
+
+  GdkContentProvider *content;
+  GdkDragAction action;
+
+  guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
+};
+
+void     gdk_drag_set_cursor          (GdkDrag        *drag,
+                                       GdkCursor      *cursor);
+void     gdk_drag_set_actions         (GdkDrag        *drag,
+                                       GdkDragAction   actions,
+                                       GdkDragAction   suggested_action);
+
+void     gdk_drag_cancel              (GdkDrag        *drag,
+                                       GdkDragCancelReason  reason);
+gboolean gdk_drag_handle_source_event (GdkEvent       *event);
+GdkCursor * gdk_drag_get_cursor       (GdkDrag        *drag,
+                                       GdkDragAction   action);
+
+void     gdk_drag_abort               (GdkDrag        *drag,
+                                       guint32         time_);
+void     gdk_drag_drop                (GdkDrag        *drag,
+                                       guint32         time_);
+
+void     gdk_drag_write_async         (GdkDrag             *drag,
+                                       const char          *mime_type,
+                                       GOutputStream       *stream,
+                                       int                  io_priority,
+                                       GCancellable        *cancellable,
+                                       GAsyncReadyCallback  callback,
+                                       gpointer             user_data);
+gboolean gdk_drag_write_finish        (GdkDrag             *drag,
+                                       GAsyncResult        *result,
+                                       GError             **error);
+
+
+G_END_DECLS
+
+#endif
index 7d810d9fda788afe3fe5d50ba87e174ebe76a1d3..e648110212f4b686afd2b6af4b5470d562bca112 100644 (file)
@@ -28,7 +28,7 @@
 #include "gdkeventsprivate.h"
 #include "gdkinternals.h"
 #include "gdkdisplayprivate.h"
-#include "gdkdndprivate.h"
+#include "gdkdragprivate.h"
 #include "gdkdropprivate.h"
 #include "gdk-private.h"
 
index e8577af1a1edcd676b87fdf7e974d9518ffcd9e7..f496502ad247a5256710e6b999c122b9f7ae699a 100644 (file)
@@ -31,7 +31,7 @@
 
 #include <gdk/gdkversionmacros.h>
 #include <gdk/gdktypes.h>
-#include <gdk/gdkdnd.h>
+#include <gdk/gdkdrag.h>
 #include <gdk/gdkdevice.h>
 #include <gdk/gdkdevicetool.h>
 
index b706c6f383b0ec7f2bf14739c8368a2ff849b3b0..a7ab6a88ab11f917b118ece706c38c73b7331cdf 100644 (file)
@@ -26,7 +26,7 @@
 #define __GDK_EVENTS_PRIVATE_H__
 
 #include <gdk/gdktypes.h>
-#include <gdk/gdkdnd.h>
+#include <gdk/gdkdrag.h>
 #include <gdk/gdkdevice.h>
 #include <gdk/gdkdevicetool.h>
 
index f77ed09e6fb32631f471ebfadc4bd1a67a32ee45..69b5f844f1ee20f3c14d4e9d6f629709b4720197 100644 (file)
@@ -32,7 +32,7 @@
 #include "gdkdisplay.h"
 #include "gdkeventsprivate.h"
 #include "gdkenumtypes.h"
-#include "gdkdndprivate.h"
+#include "gdkdragprivate.h"
 
 G_BEGIN_DECLS
 
index 4a2e24073c12598d80d489c59caf96d70be25d41..d68307392b107e51407848a78b8db50a76cb619e 100644 (file)
@@ -15,7 +15,7 @@ gdk_public_sources = files([
   'gdkdevicetool.c',
   'gdkdisplay.c',
   'gdkdisplaymanager.c',
-  'gdkdnd.c',
+  'gdkdrag.c',
   'gdkdrawcontext.c',
   'gdkdrop.c',
   'gdkevents.c',
@@ -65,7 +65,7 @@ gdk_public_headers = files([
   'gdkdevicetool.h',
   'gdkdisplay.h',
   'gdkdisplaymanager.h',
-  'gdkdnd.h',
+  'gdkdrag.h',
   'gdkdrawcontext.h',
   'gdkdrop.h',
   'gdkevents.h',
index 5b9792028b81a26a5386716e1768755890c828c1..4288693766762b4a12d4adb34dcb9633b757b6bc 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "config.h"
 
-#include "gdkdndprivate.h"
+#include "gdkdragprivate.h"
 
 #include "gdkinternals.h"
 #include "gdkproperty.h"
index 39380537a241bdc6b16f050a78a2d2b29f56e16f..9683a5a8ed03b069fb5de17e35b5f937d462a178 100644 (file)
@@ -28,7 +28,6 @@
 #include "gdkprivate-wayland.h"
 #include "gdkdisplay-wayland.h"
 #include "gdkcontentformatsprivate.h"
-#include "gdkdndprivate.h"
 #include "gdkproperty.h"
 
 #include <string.h>
index 8377636a4ed7dbdcb6d9a90a215b4af667556de3..383cc09e47dffea7c4d191cc8fa5e2414b177cbf 100644 (file)
@@ -32,7 +32,7 @@
 #include "gdkclipboard-x11.h"
 #include "gdkdeviceprivate.h"
 #include "gdkdisplay-x11.h"
-#include "gdkdndprivate.h"
+#include "gdkdragprivate.h"
 #include "gdkinternals.h"
 #include "gdkintl.h"
 #include "gdkproperty.h"
index c07f423fd55397683620e637f12d99aa43e5fd34..6a71b55cf3466bda3c68ee5978feeeeb3ca8df2b 100644 (file)
@@ -32,7 +32,7 @@
 #include "gdkclipboard-x11.h"
 #include "gdkdeviceprivate.h"
 #include "gdkdisplay-x11.h"
-#include "gdkdndprivate.h"
+#include "gdkdragprivate.h"
 #include "gdkinternals.h"
 #include "gdkintl.h"
 #include "gdkproperty.h"